const fs = require('fs');
const path = require('path');
const JSON5 = require('json5');
const Mock = require('mockjs');

function getJson5File(filePath) {
  var jsonData = fs.readFileSync(path.join(__dirname, './test.json5'), 'utf-8');
  return JSON5.parse(jsonData);
}

module.exports = function (app) {
  // 监听请求
  app.get("/user/userInfo", function (req, res) {
    var jsonObj = getJson5File('./test.json5');
    res.json(Mock.mock(jsonObj));
  });
};
